<template>
  <div class="record">

    <div class="main">
      <div class="imgr">
        <!-- <img class="auto-img" src="../assets/img/skypixel.jpg" alt="" /> -->
      </div>
      <div class="login">
        <h1>登录</h1>
        <p style="margin-top: 30px">请输入你的邮箱账号／手机</p>
        <input type="text" v-model="phone" />
        <p>请输入密码</p>
        <input type="password" v-model="password" />
        <br />
        <div class="che">
          <div class="left">
            <input type="checkbox" /> <span>记住密码</span>
          </div>
          <a href="#">忘记密码？</a>
        </div>
        <button @click="submit">登录</button>
        <br />
        <span
          >还没账号？<router-link to="/register" style="color: #1088f2"
            >注册</router-link
          ></span
        >
      </div>
    </div>
    <foot-navbar></foot-navbar>
  </div>
</template>

<script>
import FootNavbar from "../components/FootNavbar.vue";


export default {
  components: { FootNavbar },
  data() {
    return {
      phone: "",
      password:"",
    };
  },
  methods:{
    submit(){
        // 1.验证手机号码
        let reg = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
        // 2.验证密码
        let pass = /^[a-zA-Z0-9]\w{8,17}$/;
        if(!reg.test(this.phone) || !pass.test(this.password) ){//不正确处理
            this.$message.error('请输入正确手机号码与密码');
            return;
        }
        this.$emit("login_local");
        window.localStorage.setItem("token","token值");
        window.localStorage.setItem("userId","666");
        this.$message.success('登录成功');
        // this.$router.push("/my");
        //登录成功返回上一页
        this.$router.go(-1);
    }
  }
};
</script>

<style lang="scss" scoped>
.record {
  .foot {
    position: fixed;
    bottom: 0;
    width: 100%;
  }
  .main {
    display: flex;
    height: 100%;
  }
  .imgr {
    margin-bottom: -3px;
    width: 50%;
    height: 90vh;
    background-size: cover;
    background-position: 50%;
    background-image: url('../assets/img/skypixel.jpg');
  }
  .login {
    width: 50%;
    padding-right: 12%;
    box-sizing: border-box;
    padding-left: 88px;
    margin-top: 50px;
    h1 {
      font-size: 40px;
    }
    p {
      font-weight: bold;
      margin: 10px 0;
      &:first-child {
        margin-top: 30px;
      }
    }
    input {
      width: 100%;
      height: 41px;
      box-sizing: border-box;
      outline: yellow;
      border: 1px solid #ccc;
      padding: 12px;
      border-radius: 5px;
    }
    button {
      margin: 30px 0;
      width: 100%;
      height: 41px;
      background-color: #1088f2;
      border: 0;
      border-radius: 5px;
      color: #fff;
      font-weight: bold;
    }
  }
  .che {
    margin-top: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .left {
      display: flex;
      align-items: center;
    }
    input {
      width: 16px;
      height: 16px;
      margin-right: 10px;
    }
  }
}
</style>